package ynu.lcy.elememicroserviceuserauthservice9091.chain;


import ynu.lcy.elememicroservicecommon.exception.BusinessException;
import ynu.lcy.elememicroservicecommon.utils.ErrorCode;

/**
 * 校验手机号格式
 * */
public class PhoneFormatHandler extends AbstractAuthenticationHandler {
    @Override
    public void handle(AuthenticationContext context) throws BusinessException {
        if (!context.getPhoneNumber().matches("^1\\d{2}$")) {
            throw new BusinessException(ErrorCode.Authentication_ERROR,"手机号格式错误");
        }
        handleNext(context);
    }
}
